import request from "../../util/request"

// pages/home/home.js
Page({

    /**
     * 页面的初始数据
     */
    data: {
        loopList: [],
        goodList: [],
        total_people: 1,
        piclist: ["/images/2C57B1B5E9228275C4E0902E8C1DA7A6.jpg",
        "/images/2F37AE51AE61436523847D95699F0BF2.jpg",
        "/images/A175A9F70A2D7CF1BB41F2CFB92538E5.jpg",
        "/images/E46A33154E4B33A0C117BAD9B142F00D.jpg"],
        Time:0,
        num:0,
        totalIn:0,
        totalOut:0,
    },

    current: 1,
    total: 0,
    

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function () {
        this.setData({
            num:0,
            Time:0,
            totalIn:0,
            totalOut:0,
        })
        wx.cloud.callFunction({
            name:"getNum"
        }).then(res=>{
            const result=res.result
            this.setData({
                num:result.totalIn-result.totalOut,
                totalIn:result.totalIn,
                totalOut:result.totalOut
            })
            console.log(result)
        })


    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {
        setInterval(()=>{
            var a=this.data.Time
            a=a+1
            this.setData({Time:a})
            if(a==31){this.onLoad()}

    },1000)
    },


    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload:function(){

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {
        if(this.data.goodList.length === this.total){
            return
        }

        this.current++
        this.renderGoods()
    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    },


})